//
//  HYFNaViGaTionController.m
//  hyf-BaiSi
//
//  Created by Bill on 16/6/16.
//  Copyright © 2016年 hyf. All rights reserved.
//

#import "HYFNaViGaTionController.h"

@interface HYFNaViGaTionController ()<UIGestureRecognizerDelegate>//全屏滑动功能实现1

@end



@implementation HYFNaViGaTionController


-(void)viewDidLoad{
    [super viewDidLoad];
    //全屏滑动功能实现2
    id target = self.interactivePopGestureRecognizer.delegate;
    // 创建全屏滑动手势
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    // 控制全屏手势什么时候触发
    pan.delegate = self;
    [self.view addGestureRecognizer:pan];
    
    // 限制系统边缘滑动手势
    self.interactivePopGestureRecognizer.enabled = NO;
   
}

//全屏滑动功能3：
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{

    // 每次触发手势的时候就会调用
    // 判断下当前在不在根控制器
    return self.childViewControllers.count > 1;

}



//自己的事情自己做
+ (void)load
{
    // 获取全局导航条
    
    // 获取当前类的导航条
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedIn:self, nil];
    
    // iOS7适配: Bug:在做发短信功能的时候,发现联系人黑屏
    
    // 设置导航条标题字体
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSFontAttributeName] = [UIFont boldSystemFontOfSize:20];
    [bar setTitleTextAttributes:attr];
    
    // 设置导航条背景图片
    [bar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
    
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.childViewControllers.count>0) {
        //创建返回按钮文字部分
        UIButton *goback=[UIButton buttonWithType:UIButtonTypeCustom];
        [goback setTitle:@"返回" forState:UIControlStateNormal];
        [goback setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [goback setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        //创建按钮图片部分
        [goback setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
        [goback setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
        
        [goback addTarget:self action:@selector(ff) forControlEvents:UIControlEventTouchUpInside];
        [goback sizeToFit];
        goback.contentEdgeInsets=UIEdgeInsetsMake(0, -20, 0, 0);
        
        self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:goback];
    
    
    }
    //实行跳转
    [super pushViewController:viewController animated:animated];

}

-(void)ff{

    [self popViewControllerAnimated:YES];

}


//全屏滑动功能实现






@end
